
package org.openhds.domain.model;

import java.io.Serializable;
import java.util.Calendar;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.openhds.domain.annotations.Description;
import org.openhds.domain.constraint.CheckCalendar;
import org.openhds.domain.constraint.CheckInMigrationAfterDob;
import org.openhds.domain.constraint.CheckIndividualNotUnknown;
import org.openhds.domain.constraint.ExtensionIntegerConstraint;
import org.openhds.domain.constraint.Searchable;


/**
 * Generated by JCodeModel
 * 
 */
@Description(description = "An InMigration represents a migration into the study area. It contains information about the Individual who is in-migrating to a particular Residency. It also contains information about the origin, date, and reason the Indiviudal is migrating as well as the Visit that is associated with the migration.")
@Entity
@CheckInMigrationAfterDob
@Table(name = "inmigration")
@XmlRootElement(name = "inmigration")
public class InMigration
    extends VisitableEntity
    implements Serializable
{

    public final static long serialVersionUID = 7889700709284952892L;
    @NotNull
    @Searchable
    @ManyToOne
    @CheckIndividualNotUnknown
    @Description(description = "Individual who is inmigrating, identified by external id.")
    private Individual individual = new Individual();
    @OneToOne
    @NotNull
    @Description(description = "The residency the individual is inmigrating to.")
    private Residency residency = new Residency();
    @Searchable
    @ExtensionIntegerConstraint(constraint = "placeMovedFromConstraint", message = "Invalid Value for origin", allowNull = true)
    @Description(description = "Name of the social group.")
    private Integer origin;
    @Searchable
    @ExtensionIntegerConstraint(constraint = "reasonForInmigrationConstraint", message = "Invalid Value for reason", allowNull = true)
    @Description(description = "Name of the social group.")
    private Integer reason;
    @NotNull
    @CheckCalendar(message = "Recorded date is invalid")
    @Temporal(TemporalType.DATE)
    @Description(description = "Recorded date of the inmigration.")
    private Calendar recordedDate;
    @Enumerated(EnumType.STRING)
    @Description(description = "The migration type.")
    private MigrationType migType = MigrationType.INTERNAL_INMIGRATION;
    @Description(description = "Flag for indicating if the individual who is inmigrating is known or not.")
    private Boolean unknownIndividual;
    @Searchable
    @ManyToOne
    @Description(description = "Moving to house.")
    private Location house;
    @Description(description = "Moving to house name")
    private String houseName;
    @Searchable
    @ManyToOne
    @Description(description = "Moving to household.")
    private SocialGroup household;
    @Description(description = "Moving to house name")
    private String householdName;
    @Description(description = "Flag that indicates whether the inmigration references a temporary individual. A temporary individual is an individual who was once registered in the HDS but does not know their permanent id. In this situation, a temporary id (and individual) is created which should be reconciled later.")
    private Boolean referencesTemporaryIndividual = false;
    @Description(description = "Date of interview for the inmigration")
    @CheckCalendar(message = "Invalid value for date")
    @Temporal(TemporalType.DATE)
    @Past
    private Calendar dateOfInterview;
    @Description(description = "Old village of the place where the migrant is moving from")
    private String villageMovingFrom;
    @Description(description = "Old cell phone number of the place where the migrant is moving from")
    private String cellPhoneNumberMovingFrom;
    @Description(description = "If reason for the inmigration is other, please specify")
    private String reasonOther;
    @Description(description = "Temporary Id of the migrant")
    private String currentIndividualNumber;
    @Description(description = "Old name of the place where the migrant was first registered")
    private String oldNameFirstReg;
    @Description(description = "Old house name of the place where the migrant was first registered")
    private String houseNameFirstReg;
    @Description(description = "Old cell phone number of the place where the migrant was first registered")
    private String cellPhoneNumberFirstReg;
    @Description(description = "Old name of the place where the migrant is moving from")
    private String oldNameMovingFrom;
    @Description(description = "Number of years of formal education")
    private Integer formalEducationYears;
    @Description(description = "Old household name of the place where the migrant is moving from")
    private String householdNameMovingFrom;
    @Description(description = "Old section of the place where the migrant is moving from")
    private String sectionMovingFrom;
    @Description(description = "Old section of the place where the migrant was first registered")
    private String sectionFirstReg;
    @Description(description = "Old household name of the place where the migrant was first registered")
    private String householdNameFirstReg;
    @Description(description = "Old house name of the place where the migrant is moving from")
    private String houseNameMovingFrom;
    @Description(description = "Has the member ever been registered")
    @ExtensionIntegerConstraint(constraint = "yesNoConstraint", message = "Invalid Value for everRegistered", allowNull = true)
    private Integer everRegistered;
    @Description(description = "Relationship type to the group head")
    private String bIsToA;
    @Description(description = "If the origin for the inmigration is other, place specify")
    private String originOther;
    @Description(description = "Old village of the place where the migrant was first registered")
    private String villageFirstReg;

    public Individual getIndividual() {
        return individual;
    }

    public void setIndividual(Individual indiv) {
        individual = indiv;
    }

    public Residency getResidency() {
        return residency;
    }

    public void setResidency(Residency res) {
        residency = res;
    }

    public Integer getOrigin() {
        return origin;
    }

    public void setOrigin(Integer name) {
        origin = name;
    }

    public Integer getReason() {
        return reason;
    }

    public void setReason(Integer name) {
        reason = name;
    }

    @XmlJavaTypeAdapter(org.openhds.domain.util.CalendarAdapter.class)
    public Calendar getRecordedDate() {
        return recordedDate;
    }

    public void setRecordedDate(Calendar date) {
        recordedDate = date;
    }

    public MigrationType getMigType() {
        return migType;
    }

    public void setMigType(MigrationType mig) {
        migType = mig;
    }

    public Boolean isUnknownIndividual() {
        return unknownIndividual;
    }

    public void setUnknownIndividual(Boolean flag) {
        unknownIndividual = flag;
    }

    public Location getHouse() {
        return house;
    }

    public void setHouse(Location place) {
        house = place;
    }

    public String getHouseName() {
        return houseName;
    }

    public void setHouseName(String houseName) {
        this.houseName = houseName;
    }

    public SocialGroup getHousehold() {
        return household;
    }

    public void setHousehold(SocialGroup place) {
        household = place;
    }

    public String getHouseholdName() {
        return householdName;
    }

    public void setHouseholdName(String householdName) {
        this.householdName = householdName;
    }

    public Boolean isReferencesTemporaryIndividual() {
        return referencesTemporaryIndividual;
    }

    public void setReferencesTemporaryIndividual(Boolean referencesTemporaryIndividual) {
        this.referencesTemporaryIndividual = referencesTemporaryIndividual;
    }

    @Override
    public String toString() {
        return "In Migration";
    }

    public void setMigTypeInternal() {
        setMigType(MigrationType.INTERNAL_INMIGRATION);
    }

    public void setMigTypeExternal() {
        setMigType(MigrationType.EXTERNAL_INMIGRATION);
    }

    @XmlJavaTypeAdapter(org.openhds.domain.util.CalendarAdapter.class)
    public Calendar getDateOfInterview() {
        return dateOfInterview;
    }

    public void setDateOfInterview(Calendar data) {
        dateOfInterview = data;
    }

    public String getVillageMovingFrom() {
        return villageMovingFrom;
    }

    public void setVillageMovingFrom(String data) {
        villageMovingFrom = data;
    }

    public String getCellPhoneNumberMovingFrom() {
        return cellPhoneNumberMovingFrom;
    }

    public void setCellPhoneNumberMovingFrom(String data) {
        cellPhoneNumberMovingFrom = data;
    }

    public String getReasonOther() {
        return reasonOther;
    }

    public void setReasonOther(String data) {
        reasonOther = data;
    }

    public String getCurrentIndividualNumber() {
        return currentIndividualNumber;
    }

    public void setCurrentIndividualNumber(String data) {
        currentIndividualNumber = data;
    }

    public String getOldNameFirstReg() {
        return oldNameFirstReg;
    }

    public void setOldNameFirstReg(String data) {
        oldNameFirstReg = data;
    }

    public String getHouseNameFirstReg() {
        return houseNameFirstReg;
    }

    public void setHouseNameFirstReg(String data) {
        houseNameFirstReg = data;
    }

    public String getCellPhoneNumberFirstReg() {
        return cellPhoneNumberFirstReg;
    }

    public void setCellPhoneNumberFirstReg(String data) {
        cellPhoneNumberFirstReg = data;
    }

    public String getOldNameMovingFrom() {
        return oldNameMovingFrom;
    }

    public void setOldNameMovingFrom(String data) {
        oldNameMovingFrom = data;
    }

    public Integer getFormalEducationYears() {
        return formalEducationYears;
    }

    public void setFormalEducationYears(Integer data) {
        formalEducationYears = data;
    }

    public String getHouseholdNameMovingFrom() {
        return householdNameMovingFrom;
    }

    public void setHouseholdNameMovingFrom(String data) {
        householdNameMovingFrom = data;
    }

    public String getSectionMovingFrom() {
        return sectionMovingFrom;
    }

    public void setSectionMovingFrom(String data) {
        sectionMovingFrom = data;
    }

    public String getSectionFirstReg() {
        return sectionFirstReg;
    }

    public void setSectionFirstReg(String data) {
        sectionFirstReg = data;
    }

    public String getHouseholdNameFirstReg() {
        return householdNameFirstReg;
    }

    public void setHouseholdNameFirstReg(String data) {
        householdNameFirstReg = data;
    }

    public String getHouseNameMovingFrom() {
        return houseNameMovingFrom;
    }

    public void setHouseNameMovingFrom(String data) {
        houseNameMovingFrom = data;
    }

    public Integer getEverRegistered() {
        return everRegistered;
    }

    public void setEverRegistered(Integer data) {
        everRegistered = data;
    }

    public String getBIsToA() {
        return bIsToA;
    }

    public void setBIsToA(String data) {
        bIsToA = data;
    }

    public String getOriginOther() {
        return originOther;
    }

    public void setOriginOther(String data) {
        originOther = data;
    }

    public String getVillageFirstReg() {
        return villageFirstReg;
    }

    public void setVillageFirstReg(String data) {
        villageFirstReg = data;
    }

}
